import React from 'react';
import user from "./dataContext/user";

class FirstComponent extends React.PureComponent {
    constructor() {
        super();
        this.state = {
            username: '',
        }
    }
    changeUserName = function () {
        user.set('111')
    };
    render() {
        const { username } = this.state;
        return (
            <div>
                <div>
                    <h3>FirstComponent <button onClick={this.changeUserName}>change111</button></h3>
                    <h5>username: {username}</h5>
                </div>
            </div>
        )
    }
    componentDidMount() {
        user.addListener(e => {
            this.setState({
                'username': user.get()
            })
        })
    }
}
export default FirstComponent